package newsOrganizer;

import java.awt.Component;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JLabel;

/**
 * 
 * @author macitu
 *
 * Class with additinal field uri that opens on rigth click on the MyURLlabel
 * 
 * 
 */
public class MyURLLabel extends JLabel implements MouseListener{

public MyURLLabel() {
		super();
		this.addMouseListener(this);		
	}

private URI link ;


public URI getLink() {
	return link;
}

public void setLink(URI link) {
	this.link = link;
}

public void mouseClicked(MouseEvent e) {
	// TODO Auto-generated method stub
	
}

@Override
public void mouseEntered(MouseEvent e) {
	setCursor(new Cursor(Cursor.HAND_CURSOR));
}

@Override
public void mouseExited(MouseEvent e) {
	setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}

@Override
public void mousePressed(MouseEvent e) {
   if(e.getButton() == 1){
	   try {
			Desktop.getDesktop().browse(link);
		} catch (IOException ex) {
			//Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null,
			//		ex);
		}
   }
   if(e.getButton() == 3){
	   //open menu
   }
	
}

@Override
public void mouseReleased(MouseEvent e) {
	// TODO Auto-generated method stub
	
}

public void setLocation(int i, int y) {
	
	super.setLocation(i, y);
}
}
